package bairui.international.weixin.portal.miniapp.controller.order.manage;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_BranchCompanyStaff;
import bairui.international.model.domain.jpa.TB_User;
import bairui.international.service.Service_BranchCompanyStaff;
import bairui.international.service.Service_User;
import lombok.Getter;

/**
 *
 * 分配列表
 *
 * @generated
 * 
 * @see STest_C_Order_Manage_AssignPage_Get 测试
 *
 */
@Controller
public class C_Order_Manage_AssignPage_Get
 extends SC_Order_Manage_AssignPage_Get 
{
	
	@Autowired private Service_BranchCompanyStaff service_BranchCompanyStaff;
	@Autowired private Service_User service_User;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request,
		@RequestParam String skey
	) throws Exception {
		TB_User user = service_User.findOne(it->it.skey.eq(skey));
		TB_BranchCompanyStaff branchCompanyStaff = service_BranchCompanyStaff.getActive(user);
		//
		return service_BranchCompanyStaff
			.list(it->it.branchCompany.eq(branchCompanyStaff.getBranchCompany()).and(it.directorFlag.isFalse()))
			.stream()
			.map(it->new Output(it));
	}
	
	public static class Output{

		private @Getter Long id;
		private @Getter String realName;
		private @Getter String nickName;
		private @Getter String userImg;

		public Output(TB_BranchCompanyStaff it) {
			this.id = it.getId();
			TB_User user = it.getUser();
			this.realName = user.getRealName();
			this.nickName = user.getNickName();
			this.userImg = user.getAvatarUrl();
		}
		
	}

}
